﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using DAO;

namespace Sklad.WindowsApplication
{
    public partial class Authorization : Form
    {
        public Authorization()
        {
            InitializeComponent();
        }

        private void btn_ok_Click(object sender, EventArgs e)
        {
            DaoRepository dao = new DaoRepository();
            if (dao.EmployeeRepository.IsUserValid(txt_login.Text, txt_password.Text))
            {
                if ((bool)dao.EmployeeRepository.IsAdmin(txt_login.Text))
                {
                    this.Visible = false;
                    AdminMainForm amf = new AdminMainForm();
                    amf.Visible = true;
                }
                else
                {
                    this.Visible = false;
                    MainEmployeeForm mef = new MainEmployeeForm();
                    mef.Visible = true;
                }
            }
            else
            {
                MessageBox.Show("ERROR");
            }
        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            Application.Exit();
        }
    }
}
